package net.wang.staffing_system.controller;

import net.wang.staffing_system.service.FileService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Logger;

/**
 *
 */
@RestController
@RequestMapping(value = "/file")
public class FileController {
    private final Logger logger = Logger.getLogger(this.getClass().getName());
    @Resource
    private FileService fileService;

    @PostMapping(value = "/excel")
    public Map<String, Object> uploadExcel(MultipartFile file) throws IOException {
        logger.info(file.getOriginalFilename());
        return fileService.saveExcel(file);

    }

    @PostMapping(value = "/csv")
    public Map<String, Object> uploadCsv(MultipartFile file) throws IOException {
        logger.info(file.getOriginalFilename());
        return fileService.saveCSV(file);
    }

}
